package com.zl.web.controller.classroommanagement;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.zl.common.annotation.Log;
import com.zl.common.core.controller.BaseController;
import com.zl.common.core.domain.AjaxResult;
import com.zl.common.enums.BusinessType;
import com.zl.classroommanagement.domain.QrcdeUser;
import com.zl.classroommanagement.service.IQrcdeUserService;
import com.zl.common.utils.poi.ExcelUtil;
import com.zl.common.core.page.TableDataInfo;

/**
 * 二维码用户Controller
 *
 * @author zl
 * @date 2022-05-03
 */
@RestController
@RequestMapping("/classroommanagement/qrcodeuser")
public class QrcdeUserController extends BaseController
{
    @Autowired
    private IQrcdeUserService qrcdeUserService;

    /**
     * 查询二维码用户列表
     */
    @PreAuthorize("@ss.hasPermi('classroommanagement:qrcodeuser:list')")
    @GetMapping("/list")
    public TableDataInfo list(QrcdeUser qrcdeUser)
    {
        //startPage();
        List<QrcdeUser> list = qrcdeUserService.selectQrcdeUserList(qrcdeUser);
        return getDataTable(list);
    }

    /**
     * 导出二维码用户列表
     */
    @PreAuthorize("@ss.hasPermi('classroommanagement:qrcodeuser:export')")
    @Log(title = "二维码用户", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, QrcdeUser qrcdeUser)
    {
        List<QrcdeUser> list = qrcdeUserService.selectQrcdeUserList(qrcdeUser);
        ExcelUtil<QrcdeUser> util = new ExcelUtil<QrcdeUser>(QrcdeUser.class);
        util.exportExcel(response, list, "二维码用户数据");
    }

    /**
     * 获取二维码用户详细信息
     */
    @PreAuthorize("@ss.hasPermi('classroommanagement:qrcodeuser:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(qrcdeUserService.selectQrcdeUserById(id));
    }

    /**
     * 新增二维码用户
     */
    @PreAuthorize("@ss.hasPermi('classroommanagement:qrcodeuser:add')")
    @Log(title = "二维码用户", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody QrcdeUser qrcdeUser)
    {
        return toAjax(qrcdeUserService.insertQrcdeUser(qrcdeUser));
    }

    /**
     * 修改二维码用户
     */
    @PreAuthorize("@ss.hasPermi('classroommanagement:qrcodeuser:edit')")
    @Log(title = "二维码用户", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody QrcdeUser qrcdeUser)
    {
        return toAjax(qrcdeUserService.updateQrcdeUser(qrcdeUser));
    }

    /**
     * 删除二维码用户
     */
    @PreAuthorize("@ss.hasPermi('classroommanagement:qrcodeuser:remove')")
    @Log(title = "二维码用户", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(qrcdeUserService.deleteQrcdeUserByIds(ids));
    }

    /**
     * 根据二维码信息修改用户状态
     * @param teachercard
     * @param userName
     * @return
     */
    @GetMapping("qrcodeuserByStatus")
    public AjaxResult qrcodeuserByStatus(@RequestParam("teachercard") Long teachercard,@RequestParam("userName") String userName){

        return AjaxResult.success(qrcdeUserService.qrcodeuserByStatus(teachercard,userName));
    }


}
